package liquidfs.data;

import com.thoughtworks.xstream.annotations.*;

@XStreamAlias("revision")
public class Revision {
   
   private PeerDevice device;
   
   @XStreamAsAttribute()
   @XStreamAlias("number")
   private long revisionNumber;
   
   public Revision (PeerDevice device, long revisionNumber) {
      this.device = device;
      this.revisionNumber = revisionNumber;
   }

   public PeerDevice getDevice() {
      return device;
   }

   public long getRevisionNumber() {
      return revisionNumber;
   }
   
   public int hashCode () {
      return (int) (device.hashCode() ^ revisionNumber);
   }
   
   public boolean equals (Object other) {
      
      if (other instanceof Revision) {
         Revision revision = (Revision) other;
         return this.device.getID().equalsIgnoreCase(revision.getDevice().getID()) && this.revisionNumber == revision.getRevisionNumber();
      }
      
      return false;
      
   }
}
